#include "StdAfx.h"
#include "ZMatrices.h"

ZMatrices::ZMatrices(VOID)
{
	Init();
}

ZMatrices::~ZMatrices(VOID)
{
}

VOID ZMatrices::Init()
{
	//ZeroMemory( m_ModelRotate, sizeof(m_ModelRotate) );
	ZeroMemory( m_CameraPos, sizeof(m_CameraPos) );
	m_CameraPos[2] = -15.0f;
}

//FLOAT CSetupMatrices::Get_ModelRotate( INT a_i )
//{
//	return m_ModelRotate[a_i];
//}

D3DXVECTOR3* ZMatrices::Get_vEyePt()
{
	return &m_vEyePt;
}

D3DXMATRIXA16* ZMatrices::Get_matProj()
{
	return &m_matProj;
}

D3DXMATRIXA16* ZMatrices::Get_matCullProj()
{
	D3DXMatrixPerspectiveFovLH( &m_matCullProj, 0.7853981635f, 
		static_cast<FLOAT>(GCREATEDEVICE.Get_pD3dpp().BackBufferWidth) / static_cast<FLOAT>(GCREATEDEVICE.Get_pD3dpp().BackBufferHeight), 
		1.0f, 1000.0f );
	return &m_matCullProj;
}


VOID ZMatrices::Set_CameraPos( INT a_Key, FLOAT a_Value )
{
	m_CameraPos[a_Key] += a_Value;
}


VOID ZMatrices::SetupModeltoWorld( const D3DXMATRIXA16& a_matWorld )
{
	GD3D9DEVICE->SetTransform( D3DTS_WORLD, &a_matWorld );
}

VOID ZMatrices::SetupProjection()
{
	//D3DXMATRIXA16 matProj;
	D3DXMatrixPerspectiveFovLH( &m_matProj, 0.7853981635f, 
		static_cast<FLOAT>(GCREATEDEVICE.Get_pD3dpp().BackBufferWidth) / static_cast<FLOAT>(GCREATEDEVICE.Get_pD3dpp().BackBufferHeight), 
		1.0f, 10000.0f );

	GD3D9DEVICE->SetTransform( D3DTS_PROJECTION, &m_matProj );
}

VOID ZMatrices::SetupOrtho()
{

	/*D3DXMatrixPerspectiveLH( &m_matProj, 
		static_cast<FLOAT>(GCREATEDEVICE.Get_pD3dpp().BackBufferWidth), static_cast<FLOAT>(GCREATEDEVICE.Get_pD3dpp().BackBufferHeight), 
		1.0f, 10000.0f );

	GD3D9DEVICE->SetTransform( D3DTS_PROJECTION, &m_matProj );*/

	D3DXMatrixOrthoLH( &m_matProj, 
		static_cast<FLOAT>(GCREATEDEVICE.Get_pD3dpp().BackBufferWidth), 
		static_cast<FLOAT>(GCREATEDEVICE.Get_pD3dpp().BackBufferHeight), 1.0f, 100000.0f );

	GD3D9DEVICE->SetTransform( D3DTS_PROJECTION, &m_matProj );
}